package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import org.testng.annotations.Test;

import com.example.utils.SortedListOf;

public class AlsoGroupCreationTests extends TestBase {
		
@Test
public void testNonEmptyGroupCreation() throws Exception {
		// save old state
		SortedListOf<GroupData> oldList = app.getGroupHelper().getGroups();
        
		// actions
		app.getGroupHelper().initGroupCreation();
		GroupData group = new GroupData()
			.withName("also group name 1")
			.withHeader("also header 1")
			.withFooter("also footer 1");
        app.getGroupHelper()
        	.fillGroupForm(group)
        	.submitGroupCreation()
        	.returnToGroupsPage();
        
        // save new state
        SortedListOf<GroupData> newList = app.getGroupHelper().getGroups();

        // groups compare by content
		assertThat(newList, equalTo(oldList.withAdded(group)));
        }

}